<?php

class Bootstrap extends Yaf_Bootstrap_Abstract {

    public function _initConfig() {

        //$config = Yaf_Application::app()->getConfig();
        //Yaf_Registry::set("config", $config);
        // 获取配置使用 Yaf_Application::app()->getConfig()
    }

    public function _initDefaultName(Yaf_Dispatcher $dispatcher) {
        //$dispatcher->setDefaultModule("Index")->setDefaultController("Index")->setDefaultAction("index");
    }

    public function _initRoute(Yaf_Dispatcher $dispatcher) {
        /* $router = Yaf_Dispatcher::getInstance()->getRouter();
          $arr = array(
          "module" => "admin",
          "controller" => "admin",
          "action" => "index"
          );
          $route = new Yaf_Route_Regex('/^\/admin$/', $arr);
          $route1 = new Yaf_Route_Regex('/^\/$/', $arr);
          $router->addRoute("admin", $route);
          $router->addRoute("admin1", $route1);
         */

        // $router = Yaf_Dispatcher::getInstance()->getRouter();        
        /**
         * 添加配置中的路由
         */
        //$router->addConfig(Yaf_Registry::get("config")->routes);
        //$route = new Yaf_Route_Simple("m", "c", "a");
        // $router->addRoute("name", $route);
        /* 	
          // 创建路由器
          //$router = \Yaf\Dispatcher::getInstance()->getRouter();

          //创建一个简单路由协议实例
          $route = new Yaf_Route_Simple("m", "c", "a");
          //$route = new \Yaf\Route\Simple("m", "c", "a");
          //使用路由器装载路由协议
          $route->addRoute("name", $route);

          // 创建复杂的路由协议

          /*$route = new \Yaf\Route\Rewrite(
          'exp/:ident',
          array(
          'controller' => 'index',
          'action' => 'index'
          )
          );

          $router->addRoute('exp', $route); */
    }

    public function _initFunctions(Yaf_Dispatcher $dispatcher) {
        Yaf_Loader::import('Common/functions.php');
    }

}
